package com.wiloon.java8x.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;

/**
 * Created by Roy on 2015/12/1;
 */
public class HashTest {
    private static Logger logger = LoggerFactory.getLogger(HashTest.class);

    public static void main(String[] args) {
        redisHashGet();
    }

    public static void redisHashGetAll() {
        Jedis jedis = new Jedis("localhost");
        logger.debug("start get");
        jedis.hgetAll("key0");
    }

    public static void redisHashGet() {
        Jedis jedis = new Jedis("localhost");
        logger.debug("start get");
        jedis.hget("key0", "value0");
        logger.debug("end get");
        logger.debug("start get");
        jedis.hget("key0", "value1");
        logger.debug("end get");
        logger.debug("start get");
        jedis.hget("key0", "value2");
        logger.debug("end get");

    }

    public static void redisHash20w() {
        Jedis jedis = new Jedis("localhost");
        for (int i = 0; i < 200000; i++) {
            String eid = "prefix" + String.format("%06d", i) + "suffix";
            jedis.hset("key0", eid, "2015-12-01 14:06:01");
            logger.debug("add eid:{}", eid);
        }

    }

    public static void redisHash() {
        Jedis jedis = new Jedis("localhost");
        jedis.hset("key0", "value0", "2015-12-01 14:06:01");
    }

    public void redisString() {
        Jedis jedis = new Jedis("localhost");
        jedis.set("foo", "bar");
        String value = jedis.get("foo");
    }
}
